package com.wjv.example.springboot.base.controller;

import com.wjv.example.common.ResultInfo;
import com.wjv.example.springboot.base.service.HelloService;
import com.wjv.example.springboot.base.service.MySaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>Title: HelloController</p>
 *
 * @author wjv
 * @date Create in 2021/3/18 10:50
 * @description
 */
@RestController
@RequestMapping(path = "index")
public class HelloController {

    @Autowired
    private HelloService helloService;
    @Autowired
    private MySaveService mySaveService;

    @GetMapping(path = "/hello")
    public String hello() {
        return helloService.hello();
    }

    @GetMapping(path = "/hello2")
    public ResultInfo hello2 () {
        return ResultInfo.success(helloService.hello());
    }

    @GetMapping(path = "/addUser")
    public ResultInfo addUser() {
        return helloService.addUser();
    }

    @GetMapping(path = "/delUser")
    public ResultInfo delUser() {
        return helloService.delUser();
    }

    @GetMapping(path = "/getUser2")
    public ResultInfo getUser2 (int id) {
        return helloService.getUser2(id);
    }

    @GetMapping(path = "/save")
    public ResultInfo save () {
        return mySaveService.saveUser();
    }
}
